
<?php

$btn_facturar = array(
    'type' => 'submit',
    'class' => 'btn btn-sm btn-primary btn-block',
    'value' => 'Facturar'
);
$btn_no_aprobar = array(
    'type' => 'submit',
    'class' => 'btn btn-sm btn-primary btn-block',
    'value' => 'Cancelar'
);
$btn_mover = array(
    'type' => 'submit',
    'class' => 'btn btn-sm btn-primary btn-block',
    'value' => 'Mover'
);
$btn_search = array(
    'class' => 'btn btn-sm btn-primary btn-block',
    'value' => 'Buscar'
);
$filtro = array('id' => 'filtro', 'name' => 'filtro', 'class' => 'form-control', 'value' => '', 'title' => 'buscar por [nombres,apellidos,cedula] de paciente');
echo form_open('cita_medica_controller/buscar_citas');
echo '</br><div class="panel panel-default">';
echo ' <div class="panel-heading">';
echo '<h3 class="panel-title">Busqueda por criterio</h3>';
echo '</div>';
echo ' <div class="panel-body">';
echo '<div class="row-fluid">';
echo '<div class="col-sm-10">';
echo form_input($filtro);
echo '</div>';
echo '<div class="col-sm-2">';
echo form_submit($btn_search);
echo '</div>';
echo '</div>';
echo '</div>';
echo ' </div>';
echo '</br>';
echo form_close();
echo '</br><div class="panel panel-default">';
echo ' <div class="panel-heading">
    <h3 class="panel-title">Citas</h3>
  </div>';
echo ' <div class="panel-body">';
echo"<table>";
echo"<tr>";
echo"<td>";
echo '<div class="btn-group">';
echo '</div>';
echo"</td>";
echo"</tr>";
echo"</table>";
if ($citas == null) {
    echo 'No Hay Horarios';
} else {
    echo '<table cellpadding="0" cellspacing="0" border="1" class="table table-striped table-bordered table-condensed table-responsive" id="tblEspecialidades" width="100%">';
    echo "<thead>\n<tr>\n";
    echo "<th>Fecha</th><th>Hora Inicio</th><th>Hora de Fin</th><th>Paciente</th><th>Medico</th><th>Facturar</th><th>Cambiar fecha</th>\n";
    foreach ($citas as $fila) {
        $btn_editar = array(
            'class' => 'btn btn-sm btn-primary btn-block',
            'value' => 'Reservar'
        );
        echo "<tr valign='top'>\n";
        echo "<td align='left'>" . $fila['fecha'] . "</td>";
        echo "<td align='left'>" . $fila['hora_inicio'] . "</td>";
        echo "<td align='left'>" . $fila['hora_fin'] . "</td>";
        echo "<td align='left'>" . $fila['nombres_paciente'] . " " . $fila['apellidos_paciente'] . "</td>";
        echo "<td align='left'>" . $fila['nombres_medico'] . " " . $fila['apellidos_medico'] . "</td>";
        echo'<td align="left">';
        if ($fila['pago'] == "0") {
            echo form_open("facturacion_controller/crear/" . $fila['especialidad_medico_id'] . "/" . $fila['paciente_id'] . "/" . $fila['cita_id']);
            echo form_submit($btn_facturar);
            echo form_close();
        } else {
            echo 'FACTURADO';
        }
        echo'</td">';
        echo'<td align="left">';
        if ($fila['estado'] == "0") {
            $year = date('Y');
            $mes = date('m');
            echo form_open("cita_medica_controller/cambiar_agenda/" . $year . '/' . $mes . '/' . $fila['paciente_id'] . '/' . $fila['medico_id'] . '/' . $fila['cita_id']);
            echo form_submit($btn_mover);
            echo form_close();
            echo'</td">';
            echo "</tr>\n";
        } else {
            echo 'No puede cambiar fecha';
        }
    }
    echo "</tbody></table></div>";
}
echo form_close();
echo '</div>';
?>

